package cn.edu.zjut.listener;

import cn.edu.zjut.event.EmailEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author XiaoFeng
 * @version 1.0
 * @Description Create by 2021/12/4 19:57
 */

public class EmailNotifier implements ApplicationListener {
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof EmailEvent) {
            EmailEvent emailEvent = (EmailEvent) applicationEvent;
            System.out.println("需要发送邮件的接收地址 " +
                    emailEvent.getAddress());
            System.out.println("需要发送邮件的邮件正文 " +
                    emailEvent.getText());
        } else {
            System.out.println("容器本身的事件 " + applicationEvent);
        }
    }
}
